package org.example.chapter5.controller;

import org.example.chapter5.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

//@ResponseBody
//@Controller
@RestController
public class StudentController {
    @Autowired
    StudentMapper studentMapper;
    //通过id查询学生数据，返回值是RESTful风格
//    @RequestMapping(value = "/students/{id}",method = RequestMethod.GET)
    @GetMapping(value = "/students/{id}")
    public Object student(@PathVariable("id") int id) {
//        Student student = new Student();
//        student.setId(id);
//        student.setQq("1234");
        return studentMapper.getStudentById(id);
    }
}
